home *** CD-ROM | disk | FTP | other *** search
- Wildcat 4 User Database Notes
- -----------------------------
-
- The user records are stored in a fixed length Filer database. There
- are no variable length parts to a user record any more, so no matter
- how many conferences you have, a user record is the same size.
-
- The variable length parts of the user record are stored in another file
- in the same directory called USERCONF.DAT. This file has a small header:
-
- type
- TUserConfFileHeader = record
- totalconfs : Word; { total number of conferences }
- end;
-
- The header is at offset zero at the start of the file. The remainder
- of the file contains either index pages or a data pages. The index
- page has the following structure:
-
- type
- TUserConfIndex = record
- RecLen : Word; { length of this record in bytes }
- RecType : TUserConfRecType; { ucrIndex record type id }
- offsets : array [0..31] of Longint;
- end;
-
- Not all of the 32 offsets are actually used - the number that are used
- is defined by the following function:
-
- function MaxPages(MaxConfAreas : Word) : Word;
- const
- MaxChunk = 1024;
- begin
- MaxPages := (LongInt(MaxConfAreas) + MaxChunk - 1) div MaxChunk;
- end;
-
- A data page has the following structure:
-
- type
- TUserConfData = record
- cuFlags : Byte; { user's flags as defined in wctype.pas }
- cuLastRead : Word; { last read message number }
- cuFirstUnread : Word; { first unread message number }
- end;
-
- TUserConfPage = record
- RecLen : Word; { length of this record in bytes }
- RecType : TUserConfRecType; { ucrData record type id }
- UserID : LongInt; { user id number used by wcrepair }
- Page : Integer; { page number of this page }
- This : Longint; { offset of this page in bytes }
- UserConfData : array [0..1023] of TUserConfData;
- end;
-
- The ConfUser array in TConfUserPage will not always be 1024 records long.
- The size of this structure is variable length depending on the number of
- conferences defined in Makewild and is computed according to the following
- function:
-
- function PageRecords(MaxConfAreas : Word) : Word;
- const
- MaxChunk = 1024;
- var
- Chunks : Word;
- begin
- Chunks := (LongInt(MaxConfAreas) + MaxChunk - 1) div MaxChunk;
- PageRecords := ((LongInt(MaxConfAreas) + Chunks - 1) div Chunks);
- end;
-
- This function balances the space used by each record so the amount of wasted
- space is minimal. So for 1024 conferences there will be one 1024 record
- page, but for 1025 conferences the pages will be split into two 513 record
- chunks, so there is only one wasted record.
-
- There is a field called UserConfData in the fixed part of the user
- record which points to the offset of the index page for that user in
- USERCONF.DAT. Wildcat always creates an index page for each new user
- added to the database, so you can assume this page exists. However,
- not all of the data pages will exist so you have to take this into
- account and perhaps create pages as necessary (if a page does not exist
- its offset will be 0 in the index page).
-
- New pages are always created at the end of the file and old pages (from
- a deleted user, for example) are not reused. WcRepair will pack the
- USERCONF.DAT file and remove all unnecessary pages.
-
- This is a diagram of how this setup might all fit together with 1025
- conferences (with 1024 or fewer conferences there is only one user data
- page so things are kind of degenerate):
-
- ALLUSERS.DAT ofs USERCONF.DAT
- +-------------------+ 0+----------------------------+
- | | | (header) |
- . . | |
- . . 2+----------------------------+
- | | | |
- +-------------------+ . .
- | JOE USER | . .
- | (user info) | | |
- | UserConfData=50 ------>50+----------------------------+
- +-------------------+ | 61 | (index page
- | | | 2661 | for JOE USER)
- . . 61+----------------------------+
- | JOE USER, page=0, this=61 | (page 0 for JOE)
- | (513 TConfUser records) |
- 2661+----------------------------+
- | JOE USER, page=1, this=2661| (page 1 for JOE)
- | (513 TConfUser records) |
- 5261+----------------------------+
- | |
- . .
-
- All writing or modification access to the USERCONF.DAT file should be done
- only while the ALLUSERS.DAT file is locked in Filer (using BTLockFileBlock).
- This is done to prevent having to lock a regular DOS file (which is a pain
- and is also different on various networks - Filer takes care of this).
-